<?
function showtop10rcb(){
	$sqlStr = 'SELECT max( rcb ) AS rcb, name,id
			   FROM hl_listings AS A, hl_rcbrate AS B	
			   WHERE onhold=0  AND used =1 and B.program_id = A.id
			   GROUP BY name
			   ORDER BY rcb desc limit 10';
	$result = mysql_query($sqlStr);
	if($result){
		if (mysql_num_rows($result) > 0){
			echo '<table cellpadding="3" width="100%" cellspacing="0" border="0">';
			while ($row=mysql_fetch_assoc($result)){
				echo '
					<tr>
						<td ><img src="images/bullet4.jpg"></td>
						<td  align="left">
							<font color=red>'.$row['rcb'] . '%</font>  
							<a class="text_in_box" href="?a=rcb&lid='.$row['id'].'">' . $row['name'] . '</a>
						</td>
					</tr>';
			}
			echo '<tr >
					<td  align="right" class=bottom_add colspan="2">
						<a href="/?a=allrcb" class="text_in_box">ALL RCB</a>
					</td>
				</tr>';
			echo '<tr>
					<td align="right" colspan="2">
						<a href="/?a=allrcbrequest" class="text_in_box">ALL Request</a></td>
				</tr>
			</table>';
		}else
			echo('No RCB in database.');
	}else
		echo('Error in SQL query. <br>Cannot display RCB!');
	mysql_free_result($result);
}

function checkrcb($lid){
	$result=mysql_query("SELECT max(rcb) as rcb FROM hl_rcbrate WHERE onhold =0 AND used =1 AND program_id =".$lid);
	if($result){
		$row = mysql_fetch_array($result);
		$rcb = $row['rcb'];
		if ($rcb>0){
			echo  '<a href="?a=rcb&lid='.$lid.'"><font color=blue><strong>Request '.$rcb.'% RCB</strong></font></a>';
		}
	}
	mysql_free_result($result);
}

function showlastestpayout($num){
	$result=mysql_query("
		select 
				hl_statistics.listing_id, hl_statistics.type, hl_statistics.amount,hl_statistics.batch,
				date_format(hl_statistics.date, '%b %D') as date , 
				hl_listings.id, hl_listings.name, hl_listings.url 
		from 
				`hl_statistics` left outer join `hl_listings` on hl_statistics.listing_id = hl_listings.id 
		where 
				hl_statistics.type = 1 and hl_listings.name!='' 
		order by 
	
				hl_statistics.date DESC LIMIT ". $num);
	if($result){
		if (mysql_num_rows($result) > 0){
			echo '<table cellpadding="3" width="100%" cellspacing="0" border="0">';
			while ($row=mysql_fetch_assoc($result)){
				echo '<tr>';
				echo '<td><img src="images/bullet4.jpg"></td>';
				echo '<td>';
				echo '<a href="?a=go&lid='.$row['id'].'" target="_blank" class="text_in_box">'.$row['name'].'</a> 
				<span style="font-size: 7pt; color:red"> $'.$row['amount'].'</span><br>';
				echo '</td>';
				echo '</tr>';
			}
			echo '</table>';
		}else
			echo ('No payouts in database.');
	}else
		echo('Error in SQL query. <br>Cannot display latest payouts!');
	mysql_free_result($result);
}

function showlastestvote($num){
	$result=mysql_query("
		select 
				hl_votes.listing_id, hl_votes.vote, hl_votes.comment,
				date_format(hl_votes.date, '%b %D') as date , 
				hl_listings.id, hl_listings.name, hl_listings.url 
		from 
				`hl_votes` left outer join `hl_listings` on hl_votes.listing_id = hl_listings.id 
		where
	
				hl_listings.name!=''  and hl_votes.confirm = '0'
	
		order by 
	
				hl_votes.date DESC LIMIT ".$num);
	if($result){
		if (mysql_num_rows($result) > 0){
			$temp=1;
			$tempdate=$row['date'];
			while ($row=mysql_fetch_assoc($result)){
				echo '<img alt="'.$row['comment'].'" title="'.$row['comment'].'" src="./images/r'.$row['vote'].'.gif" align="absMiddle"> &nbsp<b><a href="?a=go&lid='.$row['id'].'" target="_blank">'.$row['name'].'</a></b><br>';
			}
		}
		else
			echo('No votes in database.');
	}else
		echo('Error in SQL query. <br>Cannot display latest votes!');
	mysql_free_result($result);
}

function showtop10monitored(){
	$result=mysql_query('select *, (to_days(now()) - to_days(date_added)) as monitored
                  from `hl_listings` where status=1 order by monitored desc limit 0,10');
	if($result){
		if (mysql_num_rows($result) > 0){
			echo '<table cellpadding="3" width="100%" cellspacing="0" border="0">';	
			while ($rows=mysql_fetch_array($result)){
				echo "<tr>";
				echo "<td >";
				echo '		<img src="images/bullet4.jpg">';
				echo "</td>";
				echo "<td>";
				echo '<a class="text_in_box" href="?a=go&lid='.$rows['id'].'" target="_blank">
						'.$rows['name'].' </a>
						<span style="font-size: 7pt; color:red"> '.$rows['monitored'].' days </span>';
				echo "</td>";
				echo "</tr>";
			}
			echo "</table>";
		}else
			echo('No data in database.');
	}
	else
		echo('Error in SQL query. <br>Cannot display !');
	mysql_free_result($result);
}

function notexpired($date_set){
	if ($date_set == '') { 
		return false; 
	}
	$Date_1=date("Y-m-d");
	$Date_2=$date_set;
	$Date_List_1=explode("-",$Date_1);
	$Date_List_2=explode("-",$Date_2);
	$d1=mktime(0,0,0,$Date_List_1[1],$Date_List_1[2],$Date_List_1[0]);
	$d2=mktime(0,0,0,$Date_List_2[1],$Date_List_2[2],$Date_List_2[0]);
	$Days=round(($d2-$d1)/3600/24);
	if ($Days>0 ){ 
		return true; 
	}else{ 
		return false;
	}
}

function get_toprotatingbanners (){
	$s = array ();
	$file = fopen ('inc/adsadmin/toprotatingbanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	return $s;
}

function save_toprotatingbanners (){
	global $toprotatingbanners;
	$s = array ();
	$file = fopen ('inc/adsadmin/toprotatingbanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	$file = fopen ('inc/adsadmin/toprotatingbanners.php', 'w');
	reset ($toprotatingbanners);
	fputs ($file, '<?/*
');
	while (list ($kk, $vv) = each ($toprotatingbanners)){
		if ($kk != 'logged'){
			if (!preg_match ('/_generated/', $kk)){
				fputs ($file, (('' . $kk . '	') . $vv . '
'));
				//fputs ($file, (('' . $kk . '	') . $vv . ''));
				continue;
			}
			continue;
		}
	}
	fputs ($file, '*/?>');
	fclose ($file);
}

function get_rotatingbanners (){
	$s = array ();
	$file = fopen ('inc/adsadmin/rotatingbanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	return $s;
}

function save_rotatingbanners (){
	global $rotatingbanners;
	$s = array ();
	$file = fopen ('inc/adsadmin/rotatingbanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	$file = fopen ('inc/adsadmin/rotatingbanners.php', 'w');
	reset ($rotatingbanners);
	fputs ($file, '<?/*
');
	while (list ($kk, $vv) = each ($rotatingbanners)){
		if ($kk != 'logged'){
			if (!preg_match ('/_generated/', $kk)){
				fputs ($file, (('' . $kk . '	') . $vv . '
'));
				continue;
			}
			continue;
		}
	}
	fputs ($file, '*/?>');
	fclose ($file);
}

function get_specialbanners (){
	$s = array ();
	$file = fopen ('inc/adsadmin/specialbanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	return $s;
}

function save_specialbanners1 (){
	global $specialbanners;
	$s = array ();
	$file = fopen ('inc/adsadmin/specialbanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	$file = fopen ('inc/adsadmin/specialbanners.php', 'w');
	reset ($specialbanners);
	fputs ($file, '<?/*');
	while (list ($kk, $vv) = each ($specialbanners)){
		if ($kk != 'logged'){
			if (!preg_match ('/_generated/', $kk)){
				fputs ($file, (('' . $kk . '	') . $vv . ''));
				continue;
			}
			continue;
		}
	}
	fputs ($file, '*/?>');
	fclose ($file);
}

  function save_specialbanners (){
    global $specialbanners;
    $s = array ();
    $file = fopen ('inc/adsadmin/specialbanners.php', 'r');
    if ($file) {
      while ($buf = fgets ($file, 20000)){
        $buf = chop ($buf);
        if (($buf != '<?/*' AND $buf != '*/?>')){
          list ($kk, $vv) = split ('	', $buf, 2);
          $s[$kk] = $vv;
          continue;
        }
      }
    }
    fclose ($file);
    $file = fopen ('inc/adsadmin/specialbanners.php', 'w');
    reset ($specialbanners);
    fputs ($file, '<?/*
');
    while (list ($kk, $vv) = each ($specialbanners)){
      if ($kk != 'logged'){
        if (!preg_match ('/_generated/', $kk)){
          fputs ($file, (('' . $kk . '	') . $vv . '
'));
          continue;
        }
        continue;
      }
    }
    fclose ($file);
}



function get_normalbanners (){
	$s = array ();
	$file = fopen ('inc/adsadmin/normalbanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	return $s;
}

function save_normalbanners (){
	global $normalbanners;
	$s = array ();
	$file = fopen ('inc/adsadmin/normalbanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	$file = fopen ('inc/adsadmin/normalbanners.php', 'w');
	reset ($normalbanners);
	fputs ($file, '<?/*
');
	while (list ($kk, $vv) = each ($normalbanners)){
		if ($kk != 'logged'){
			if (!preg_match ('/_generated/', $kk)){
				  fputs ($file, (('' . $kk . '	') . $vv . '
'));
				continue;
			}
			continue;
		}
	}
	fputs ($file, '*/?>');
	fclose ($file);
}

function get_minibanners (){
	$s = array ();
	$file = fopen ('inc/adsadmin/minibanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	return $s;
}

function save_minibanners (){
	global $minibanners;
	$s = array ();
	$file = fopen ('inc/adsadmin/minibanners.php', 'r');
	if ($file){
		while ($buf = fgets ($file, 20000)){
			$buf = chop ($buf);
			if (($buf != '<?/*' AND $buf != '*/?>')){
				list ($kk, $vv) = split ('	', $buf, 2);
				$s[$kk] = $vv;
				continue;
			}
		}
	}
	fclose ($file);
	$file = fopen ('inc/adsadmin/minibanners.php', 'w');
	reset ($minibanners);
	fputs ($file, '<?/*
');
	while (list ($kk, $vv) = each ($minibanners)){
		if ($kk != 'logged'){
			if (!preg_match ('/_generated/', $kk)){
				fputs ($file, (('' . $kk . '	') . $vv . '
'));
				continue;
			}
			continue;
		}
	}
	fputs ($file, '*/?>');
	fclose ($file);
}

function showmainbanner(){
	$temp=rand(1,7);
	echo '<TABLE WIDTH=760 BORDER=0 CELLPADDING=0 CELLSPACING=0 background="images/'.$temp.'.jpg" align="center" id="preloadedImages">
	        <TR>
	          <TD height="160" align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="760" height="160">
	          	<param name="movie" value="images/'.rand(1,10).'.swf">
	            <param name="quality" value="high">
				<param name="wmode" value="transparent">
		 		<embed src="images/'.rand(1,10).'.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"; type="application/x-shockwave-flash" width="760" height="160"></embed></object></TD>
	        </TR>
		</TABLE>';
}

function showminibanners(){
	global $minibanners;
	echo '
				<div class="box1 Box1Style2"><span class="Box1Text">Text/Mini Ads</span></div>
				<div class="box2">

			<table width=100% border=0 align="center" cellpadding=4 cellspacing=0>';
	$cssButoomAd ='class=bottom_add';	
	for($i=1;$i<=$minibanners['num_mini'];$i++){
		if($i== $minibanners['num_mini']){
			$cssButoomAd = '';
		}
		echo '<tr>
	    			<td align=left '.$cssButoomAd.'>';
		if($minibanners['enable_mini'.$i]=='1'){
	 	if (notexpired($minibanners['expireddate_mini'.$i])){
	 		if (strlen($minibanners['imgurl_mini'.$i])==0){
		  		echo '<div style="margin-top: 2px; text-align: center"><a href="'.$minibanners['url_mini'.$i].'" target="_blank"><strong>'.$minibanners['name_mini'.$i].'</strong></a><br>'. '<div style="margin-top: 2px; text-align: center">'.$minibanners['description_mini'.$i].'</div><small><i>Expired: '.$minibanners['expireddate_mini'.$i].'</i></small></div><br>';
	 		}else{
		 	 echo '<div style="margin-top: 2px; text-align: center"><strong>'.$minibanners['name_mini'.$i].'</strong></a><br>';
		 	 if (substr($minibanners['imgurl_mini'.$i],-4,4)=='.swf'){
		 	 	echo '<embed width="125" height="125" src="'.$minibanners['imgurl_mini'.$i].'"><noembed>'.$minibanners['url_mini'.$i].'</noembed><br>';
		 	 }
		 	 else{
		 	 	echo '<a href="'.$minibanners['url_mini'.$i].'" target="_blank"><img src='.$minibanners['imgurl_mini'.$i].' border=0 alt="'.$minibanners['description_mini'.$i].'"></a><br>';
				 }
				 echo '<small><i>Expired: '.$minibanners['expireddate_mini'.$i].'</i></small></div><br>';
	 		}
	 	}else{
	 		echo '
			<div style="text-align: right"><a href="?a=advertise"><small>your AD here for $'.($minibanners['max_mini']-($i-1)*$minibanners['step_mini']).'/Week &#187; </small></a></div><br>';
	 	}
	 }
	 echo '</td></tr>';
	}
	echo '
		</table>
		</div>
		<br>';
}

function showspecialbanners (){
	global $specialbanners;
	echo '<table width="100%" border="0"  align="center" cellpadding="0" cellspacing="0">';
	echo '	<tr>
				<td class="box1" colspan=2>
					<img src="images/t7.gif" align="left">
					<div class="side_title" align="left">Special Banners</div>
				</td>
			</tr>';
	echo '<tr>
			<td class="box2">
				<table border=0 width=100%  cellspacing="0" cellpadding="5">  ';
				$cssBottom = "class=bottom_add";
				for($i=1;$i<=$specialbanners['num_special'];$i++){
					if($i >= $specialbanners['num_special'] ){
						$cssBottom = "";
					}
					if($specialbanners['enable_special'.$i]=='1'){
					 	if (notexpired($specialbanners['expireddate_special'.$i])){
					 		echo '<tr >
					 				<td width="745" height="97" align="center" '.$cssBottom .'>
					 					<a href="'.$specialbanners['url_special'.$i].'" target="_blank">';
					 		if (substr($specialbanners['imgurl_special'.$i],-4,4)=='.swf'){
					 			echo '		<embed width="728" height="90" src="'.$specialbanners['imgurl_special'.$i].'"><noembed>'.$specialbanners['url_special'.$i].'</noembed>';
					 		}
					 		else{
					 			echo '		<img src="'.$specialbanners['imgurl_special'.$i].'" width="728" height="90" alt="'.$specialbanners['description_special'.$i].'" border="0">';
					 		}
					 		echo '		</a>
					 				</td>
							  		<td style="word-break:break-all" '.$cssBottom .'>
							  			<a href="'.$specialbanners['url_special'.$i].'" target="_blank">
							  				<strong>'.$specialbanners['name_special'.$i].'</a></strong>
							  				<br>'.$specialbanners['description_special'.$i]
					 					.'<br><a href="?a=advertise#specialbannerads" style="color:#008B00"><small><i>$'.($specialbanners['max_special']-($i-1)*$specialbanners['step_special']).'/Week or $'.(3*($specialbanners['max_special']-($i-1)*$specialbanners['step_special'])).'/Month<br>Expired: '.$specialbanners['expireddate_special'.$i].'</i></small></a>
					 				</td>
							  	</tr>';
				 	}else{
				 		echo '<tr '.$cssBottom.'>
				 				<td  height="97" width="745"  '.$cssBottom.'  align="center" >
									<div align=center class="spec_no_ad"><a href="?a=advertise#specialbannerads">
										<strong>
											<font style="font-size: 14pt; font-family: Verdana; font-weight: bold; text-decoration:underline;">
												PLACE YOUR 728*90 BANNER HERE!
											</font>
										<strong>
									</a></div>
								</td>
								 <td style=word-break:break-all '.$cssBottom.' >
									<strong>Your Program Name</strong>
									<br>Your Program Description
									<br><a href="?a=advertise#specialbannerads" style="color:#008B00">
										<small><i>$'.($specialbanners['max_special']-($i-1)*$specialbanners['step_special']).'/Week or $'.(3*($specialbanners['max_special']-($i-1)*$specialbanners['step_special'])).'/Month<br>Available Now!</i></small></a>
							     </td>
							</tr>';
				 	}
				 }
				}
				echo '
					</table>
				</td>
			   </tr>
			</table>';
}

function shownormalbanners (){
	global $normalbanners;
	echo '<table width=100% border=0 cellspacing=0 cellpadding=0>
			<tr>
				<td valign="middle" class="box1">
						<img src="images/t7.gif" align="left">
						<div class="side_title" align="left">Normal Banner</div>		
				</td>
			</tr>
		    <tr>
		    	<td class="box2">
		    		<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td valign="top"><div class="list_info">
		  				<tr><td align="center">Starting from $';
							echo $normalbanners['max_normal']-($normalbanners['num_normal']-1)*$normalbanners['step_normal'];
							echo '/Week,Increase $'.$normalbanners['step_normal'].',The higher price the higher position. </td>
						</tr>';
	$cssButoomAd ='class=bottom_add';						
	for($i=1;$i<=$normalbanners['num_normal'];$i++){
		if($i == $normalbanners['num_normal']){
			$cssButoomAd = "";
		}
		if($normalbanners['enable_normal'.$i]=='1'){
	 	echo '<tr valign="middle">
	 			<td align="center" '.$cssButoomAd.' >
	 				
					<table border="0" cellpadding="0" cellspacing="2" width="100%" style=word-break:break-all>';
	 	if (notexpired($normalbanners['expireddate_normal'.$i])){
	 		echo '<tr><td width="100%" height="64" align="center"><a href="'.$normalbanners['url_normal'.$i].'" target="_blank">';
	 		if (substr($normalbanners['imgurl_normal'.$i],-4,4)=='.swf'){
	 			echo '<embed width="468" height="60" src="'.$normalbanners['imgurl_normal'.$i].'"><noembed>'.$normalbanners['url_normal'.$i].'</noembed>';
	 		}else{
	 			echo '<img src="'.$normalbanners['imgurl_normal'.$i].'" width="468" height="60" alt="'.$normalbanners['description_normal'.$i].'" border="0">';
	 		}
	 		echo '</a></td></tr><tr><td align="center"><a href="?a=advertise#normalbannerads"><font color="#008B00"><small>Only $'.($normalbanners['max_normal']-($i-1)*$normalbanners['step_normal']).'/Week or $'.(($normalbanners['max_normal']-($i-1)*$normalbanners['step_normal'])*3).'/Month Available:'.$normalbanners['expireddate_normal'.$i].'</small></font></a></td></tr>';
			}else{
				echo '<tr><td width="100%" height="64" align="center"><a href="?a=advertise#normalbannerads"><img src="images/banner.gif" width="468" height="60" alt="banner" longdesc="okhyips.com" border="0"></a></td></tr><tr><td align="center"><a href="?a=advertise#normalbannerads"><font color="#FF0000"><small>Only $'.($normalbanners['max_normal']-($i-1)*$normalbanners['step_normal']).'/Week or $'.(($normalbanners['max_normal']-($i-1)*$normalbanners['step_normal'])*3).'/Month Available Now!</small></font></a></td></tr>';
		 }
		 echo '</table></td>
			</tr>';
		}
	}
	echo '</table></div></td></tr></table>';
}


function showtoprotatingbanners(){
	global $toprotatingbanners;
	$j=0;
	for($i=1;$i<=$toprotatingbanners['num_toprotating'];$i++){
		if ($toprotatingbanners['enable_toprotating'.$i]=='1') {
			$j++;
		}
	}
	$i=rand(1,$j);
	if (notexpired($toprotatingbanners['expireddate_toprotating'.$i])){
		echo '<a href="'.$toprotatingbanners['url_toprotating'.$i].'" target="_blank">';
		if (substr($toprotatingbanners['imgurl_toprotating'.$i],-4,4)=='.swf'){
			echo '<embed width="468" height="60" src="'.$toprotatingbanners['imgurl_toprotating'.$i].'"><noembed>'.$toprotatingbanners['url_toprotating'.$i].'</noembed>';
		}else{
			echo '<img src="'.$toprotatingbanners['imgurl_toprotating'.$i].'" width="468" height="60" alt="'.$toprotatingbanners['description_toprotating'.$i].'" border="0">';
		}
		echo '</a><br><a href="?a=advertise#toprotatingbannerads">Top Banner Ads here only $'.($toprotatingbanners['max_toprotating']-($i-1)*$toprotatingbanners['step_toprotating']).'/Week or $'.(3*($toprotatingbanners['max_toprotating']-($i-1)*$toprotatingbanners['step_toprotating'])).'/Month</a> <font style="font-size:7pt" color="#FF0000"> Available: '.$toprotatingbanners['expireddate_toprotating'.$i].'</font>';
	}else{
		echo '<a href="?a=advertise#toprotatingbannerads"><img src="images/banner.gif" width="468" height="60" alt="banner" longdesc="okhyips.com" border="0"></a><br>
			<a href="?a=advertise#toprotatingbannerads">Toprotating Banner Ads here only $'.($toprotatingbanners['max_toprotating']-($i-1)*$toprotatingbanners['step_toprotating']).'/Week or $'.(3*($toprotatingbanners['max_toprotating']-($i-1)*$toprotatingbanners['step_toprotating'])).'/Month</a> <font color="#FF0000">Available Now!</font>';		
	}

}

function showrotatingbanners(){
	global $rotatingbanners;
	$j=0;
	for($i=1;$i<=$rotatingbanners['num_rotating'];$i++){
		if ($rotatingbanners['enable_rotating'.$i]=='1') {
			$j++;
		}
	}
	$i=rand(1,$j);
	echo '<sapn  class="ad">';
	if (notexpired($rotatingbanners['expireddate_rotating'.$i])){
		echo '<a href="'.$rotatingbanners['url_rotating'.$i].'" target="_blank">';
		if (substr($rotatingbanners['imgurl_rotating'.$i],-4,4)=='.swf'){
			echo '<embed width="468" height="60" src="'.$rotatingbanners['imgurl_rotating'.$i].'"><noembed>'.$rotatingbanners['url_rotating'.$i].'</noembed>';
		}
		else{
			echo '<img src="'.$rotatingbanners['imgurl_rotating'.$i].'" width="468" height="60" alt="'.$rotatingbanners['description_rotating'.$i].'" border="0">';
		}
		echo '</a><br><a href="?a=advertise#rotatingbannerads"><font class="ad" >Rotating Banner Ads Here Only $'.($rotatingbanners['max_rotating']-($i-1)*$rotatingbanners['step_rotating']).'/Week or $'.(3*($rotatingbanners['max_rotating']-($i-1)*$rotatingbanners['step_rotating'])).'/Month</font></a> <font  class="ad"><strong> Available: '.$rotatingbanners['expireddate_rotating'.$i].'</strong></font>';
	}
	else{
		echo '<a href="?a=advertise#rotatingbannerads"><img src="images/banner.gif" width="468" height="60" alt="banner" longdesc="myhyip.net" border="0"></a><br>
			<a href="?a=advertise#rotatingbannerads"><font class="ad"  class="ad">Rotating Banner Ads Here Only $'.($rotatingbanners['max_rotating']-($i-1)*$rotatingbanners['step_rotating']).'/Week or $'.(3*($rotatingbanners['max_rotating']-($i-1)*$rotatingbanners['step_rotating'])).'/Month</font></a> <font class="ad" color="#FF0000"><strong>Available Now!</strong></font>';		
	}
	echo '</span>';
}

function showtoprotatingmin(){
	global $toprotatingbanners;
	echo $toprotatingbanners['max_toprotating'];
}

function showrotatingmin(){
	global $rotatingbanners;
	echo $rotatingbanners['max_rotating'];
}

function showspecialmin(){
	global $specialbanners;
	echo $specialbanners['max_special']-($specialbanners['num_special']-1)*$specialbanners['step_special'];
}

function shownormalmin(){
	global $normalbanners;
	echo $normalbanners['max_normal']-($normalbanners['num_normal']-1)*$normalbanners['step_normal'];
}

function showpayadform() {
	global $toprotatingbanners;
	global $rotatingbanners;
	global $specialbanners;
	global $normalbanners;
	global $minibanners;
	echo '
  <SCRIPT language=javascript type=text/javascript>	
	function adtype(){
		if(document.frm.ad_type[4].checked){			
			document.frm.ad_banner_url.disabled=false;		
			document.frm.description.disabled=true;			
			document.frm.specialbannerposition.disabled=true;	
			document.frm.normalbannerposition.disabled=true;			
			document.frm.minibannerposition.disabled=false;
		}		
		if(document.frm.ad_type[3].checked){			
			document.frm.ad_banner_url.disabled=false;		
			document.frm.description.disabled=true;			
			document.frm.specialbannerposition.disabled=true;	
			document.frm.normalbannerposition.disabled=true;			
			document.frm.minibannerposition.disabled=false;
		
		}	
		
		if(document.frm.ad_type[2].checked){			
			document.frm.ad_banner_url.disabled=false;	
			document.frm.description.disabled=false;			
			document.frm.specialbannerposition.disabled=false;	
			document.frm.normalbannerposition.disabled=true;
			document.frm.minibannerposition.disabled=true;
		
		}	
		
		if(document.frm.ad_type[0].checked||document.frm.ad_type[1].checked){			
			document.frm.ad_banner_url.disabled=false;			
			document.frm.description.disabled=false;			
			document.frm.specialbannerposition.disabled=true;	
			document.frm.normalbannerposition.disabled=true;
			document.frm.minibannerposition.disabled=true;
		}	
		SetPrice();
	}	
	function validate(frm) {	
		var ad_type = false;		
		for (counter = 0; counter < frm.ad_type.length; counter++){
			if (frm.ad_type[counter].checked)
				ad_type = true; 
		}						
		if (!ad_type){			
			alert("Please select a AD Type.")
			return (false);			
		}		
		if (frm.ad_time.value == "") {			
			alert("Please Enter Ad Time.");			
			frm.ad_time.focus();			
			return (false);		
		}		
		if (isNaN(frm.ad_time.value)) {			
			alert("Please Enter Numeric Value for Ad Time.");			
			frm.ad_time.focus();			
			return (false);		
		}		
		var ad_time_type = false;		
		for (counter = 0; counter < frm.ad_time_type.length; counter++){	
			if (frm.ad_time_type[counter].checked)
				ad_time_type = true; 	
		}			
		if (!ad_time_type){			
			alert("Please select a AD Time Type.");			
			return (false);			
		}		
		if (frm.ad_website_url.value == "") {			
			alert("Please Enter Ad Website Url.");			
			frm.ad_website_url.focus();			
			return (false);		
		}		
		if (frm.user_name.value == "") {			
			alert("Please Enter email.");			
			frm.user_name.focus();			
			return (false);		
		}		
		if (frm.ad_type[0].checked||frm.ad_type[1].checked||frm.ad_type[2].checked||frm.ad_type[3].checked){			
			if (frm.ad_banner_url.value == "") {			
				alert("Please Enter Banner Url.");			
				frm.ad_banner_url.focus();			
				return (false);			
		}			
		if (frm.description.value == "") {			
			alert("Please Enter Ad Alt Text.");			
			frm.description.focus();			
			return (false);			
			}		
		}
			
		return (true);	
	}	
</SCRIPT>
<TABLE cellSpacing=1 cellPadding=3 width="90%" align=center class=adlight border=0>
	<TR>
		<TD><!--start form-->
			<FORM name=frm method=post onsubmit="return validate(this)">
				<input type=hidden name=a value=support>
				<input type=hidden name=action value=ad>
				<TABLE cellSpacing=1 cellPadding=1 width="100%" align=center border=0 class="adlight">
					<TR>
						<TD class=text vAlign=middle colspan=2>
							<input onclick="adtype();" type="radio" checked="checked" value=0 name="ad_type" />
								<b>TOP Rotating Banner(468*60)</b>
							<br />
							<input onclick="adtype();" type="radio" value=1 name="ad_type" />
								<b>Rotating Banner(468*60)</b>
							<br />
									<INPUT onclick=adtype(); type=radio value=2 name=ad_type>
										<B>Special Banner(non-rontating,text & Description)(728*90)</B>
							<br />
							<INPUT onclick=adtype(); type=radio value=3 name=ad_type>
								<B>Normal Banner(non-ratating)(468*60)</B>
							<br />
							<input onclick="adtype();" type="radio" value="5" name="ad_type" />
								<b>  Mini banner </B>
						</TD>
					</TR>
					<tr>
						<td align=right><strong>Banner Position:<br />
							<font color=red>(FOr Special/Normal/Mini Banner ADs)</font></strong></td>
						<td>&nbsp;&nbsp;&nbsp;
							<select name="specialbannerposition" disabled onblur=adtype(); onchange=adtype(); onfocus=adtype();>	  ';
							for ($i=1;$i <= $specialbanners['num_special'];$i++){
								if(!notexpired($specialbanners['expireddate_special'.$i])){
									echo '<option value="'.$i.'" >'.$i.'</option>';													
								}
							}
							echo '</select>
							&nbsp;&nbsp;&nbsp;
							<select name="normalbannerposition" disabled   onblur=adtype(); onchange=adtype(); onfocus=adtype();>	  ';
							for ($i=1;$i<=$normalbanners['num_normal'];$i++){
								if(!notexpired($normalbanners['expireddate_normal'.$i])){
									echo '<option value="'.$i.'" >'.$i.'</option>';
								}
							}
							echo '</select>
							&nbsp;&nbsp;&nbsp;
							<select name="minibannerposition" disabled   onblur=adtype(); onchange=adtype(); onfocus=adtype();>	  ';
							for ($i=1;$i<=$minibanners['num_mini'];$i++){
								if(!notexpired($minibanners['expireddate_mini'.$i])){
									echo '<option value="'.$i.'" >'.$i.'</option>';
								}
							}
							echo '</select>
						</td>
					</tr>
					<TR>
						<TD height=30 align="right" class=text><B>Period:</B></TD>
						<TD class=text align="left">
							<INPUT onchange=SetPrice(); size=5 value=1 name=ad_time>
							<INPUT name=ad_time_type type=radio onclick=SetPrice(); value=w checked="checked" title="Weeks">
									&nbsp;<B>Weeks</B>&nbsp;&nbsp;&nbsp;&nbsp;
									<INPUT onclick=SetPrice(); type=radio value=m name=ad_time_type>&nbsp;<B>Months</B></TD></TR>
					<TR>
						<TD height=30  align="right" class=text><B>Site URL :</B></TD>
						<TD class=text align = "left">
							<INPUT size=36 name=ad_website_url></TD>
					</TR>
					<TR>
						<TD height=30 align="right" class=text><B>Contact Mail:</B></TD>
						<TD class=text align="left">
							<INPUT size=36 name=user_name></TD>
					</TR>
					<TR>
						<TD height=30 align="right"  class=text><B>Banner Url :</B>
						<TD class=text align="left">
							<INPUT disabled size=36 name=ad_banner_url></TD>
					</TR>
					<TR>
						<TD height=30 align="right" vAlign=middle class=text>
							<B>Description:</B><BR>
						<TD class=text vAlign=middle>
							<INPUT disabled size=36 name=description></TD>
					</TR>
					<TR>
						<TD height=30 align="right" class=text>
							<B>You Have to Pay :</B></td> 
						<TD class=text vAlign=middle>
							<input disabled size=5 name=total_price>
							<INPUT type=hidden size=5 name=total_price1>&nbsp;<B>$ (USD)</B></TD>
					</TR>
					<TR>
						<TD colSpan=2>&nbsp;</TD>
					</TR>
					<TR>
						<TD align="right" class=text >
							<b>Processor:</b>
						</TD>
						<TD height=30  align=left>
							<img src="images/LibertyReserve.gif" alt="LibertyReserve">
							<img src="images/PerfectMoney.gif" alt="PerfectMoney">
						</TD>
					</TR>
					<TR>
						<TD class=text vAlign=top align="center" colSpan=2>
							<INPUT class=sbmt type=submit value="Pay Now" name=btnSave>
							&nbsp;<INPUT class=sbmt id=btnClose type=reset value="  Reset  " name=reset>
						</TD>
					</TR>
				</TABLE>
			</FORM>
		</TD>
	</TR>
</TABLE>
<SCRIPT language=javascript type=text/javascript>
	function SetPrice(){
		if (isNaN(document.frm.ad_time.value)) {	
			alert("Please Enter Numeric Value for Ad Time.");	
			document.frm.ad_time.value=1;	
			document.frm.ad_time.focus();	//
			return (false);
		}
		timesWeek = 1;
		if(document.frm.ad_time_type[0].checked){
			timesWeek = 1;
		}else if(document.frm.ad_time_type[1].checked){
			timesWeek = 3;	
		}
		if(document.frm.ad_type[0].checked){
			javaprice=parseFloat(document.frm.ad_time.value*timesWeek * '.$toprotatingbanners['max_toprotating'].');	
		}else if(document.frm.ad_type[1].checked){
			javaprice=parseFloat(document.frm.ad_time.value*timesWeek * '.$rotatingbanners['max_rotating'].');
		}else if(document.frm.ad_type[2].checked){
			javaprice=parseFloat(document.frm.ad_time.value*timesWeek * ('.$specialbanners['max_special'].'-(document.frm.specialbannerposition.value-1)*'.$specialbanners['step_special'].'));
		}else if(document.frm.ad_type[3].checked){
			javaprice=parseFloat(document.frm.ad_time.value*timesWeek * ('.$normalbanners['max_normal'].'-(document.frm.normalbannerposition.value-1)*'.$normalbanners['step_normal'].'));
		}else if(document.frm.ad_type[4].checked){
			javaprice=parseFloat(document.frm.ad_time.value*timesWeek * ('.$minibanners['max_mini'].'-(document.frm.minibannerposition.value-1)*'.$minibanners['step_mini'].'));
		}
		document.frm.total_price.value=javaprice;document.frm.total_price1.value=javaprice;
	}
	adtype();
	SetPrice();
</SCRIPT> ';
}
/**
 * write ra cac vi tri  ma special banner avaiable
 */
function writeSpecialBannerPosition() {
	global $specialbanners;
	for($i = 1; $i <= $specialbanners ['num_special']; $i ++) {
		if (! notexpired ( $specialbanners ['expireddate_special' . $i] )) {
			echo '<option value="' . $i . '" >' . $i . '</option>';
		}
	}
}
/**
 * write ra cac vi tri  ma normal banner avaiable
 */
function writeNormalBannerPosition() {
	global $normalbanners;
	for($i = 1; $i <= $normalbanners ['num_normal']; $i ++) {
		if (! notexpired ( $normalbanners ['expireddate_normal' . $i] )) {
			echo '<option value="' . $i . '" >' . $i . '</option>';
		}
	}
}
/**
 * write ra cac vi tri  ma mini banner avaiable
 */
function writeMiniBannerPosition() {
	global $minibanners;
	for($i = 1; $i <= $minibanners ['num_mini']; $i ++) {
		if (! notexpired ( $minibanners ['expireddate_mini' . $i] )) {
			echo '<option value="' . $i . '" >' . $i . '</option>';
		}
	}
}

global  $_GET;
global $_POST;
global $HTTP_POST_FILES;
global $_COOKIE;
$get =  $_GET;
$post = $_POST;
$frm = array_merge ((array)$get,(array)$post);

$toprotatingbanners=get_toprotatingbanners();
$rotatingbanners=get_rotatingbanners();
$specialbanners=get_specialbanners();
$normalbanners=get_normalbanners();
$minibanners=get_minibanners();

if ($frm['a'] == 'toprotatingbanners')
{
	if (($frm['action'] == 'siads_save_action'))
	{
		$toprotatingbanners['num_toprotating'] = $frm['num_toprotating'];
		$toprotatingbanners['max_toprotating'] = $frm['max_toprotating'];
		$toprotatingbanners['step_toprotating'] = $frm['step_toprotating'];
		for($i=1;$i<=$frm['num_toprotating'];$i++){
			$toprotatingbanners['enable_toprotating'.$i] = $frm['enable_toprotating'.$i];
			$toprotatingbanners['name_toprotating'.$i] = $frm['name_toprotating'.$i];
			$toprotatingbanners['url_toprotating'.$i] = $frm['url_toprotating'.$i];
			$toprotatingbanners['imgurl_toprotating'.$i] = $frm['imgurl_toprotating'.$i];
			$toprotatingbanners['expireddate_toprotating'.$i] = $frm['expireddate_toprotating'.$i];
			$toprotatingbanners['description_toprotating'.$i] = $frm['description_toprotating'.$i];
		}
		save_toprotatingbanners ();
		header ('Location: ?a=toprotatingbanners');
		exit ();
	}
}
if ($frm['a'] == 'rotatingbanners'){
	if (($frm['action'] == 'siads_save_action')){
		$rotatingbanners['num_rotating'] = $frm['num_rotating'];
		$rotatingbanners['max_rotating'] = $frm['max_rotating'];
		$rotatingbanners['step_rotating'] = $frm['step_rotating'];
		for($i=1;$i<=$frm['num_rotating'];$i++){
			$rotatingbanners['enable_rotating'.$i] = $frm['enable_rotating'.$i];
			$rotatingbanners['name_rotating'.$i] = $frm['name_rotating'.$i];
			$rotatingbanners['url_rotating'.$i] = $frm['url_rotating'.$i];
			$rotatingbanners['imgurl_rotating'.$i] = $frm['imgurl_rotating'.$i];
			$rotatingbanners['expireddate_rotating'.$i] = $frm['expireddate_rotating'.$i];
			$rotatingbanners['description_rotating'.$i] = $frm['description_rotating'.$i];
		}
		save_rotatingbanners ();
		header ('Location: ?a=rotatingbanners');
		exit ();
	}
}
if ($frm['a'] == 'specialbanners'){
	if (($frm['action'] == 'siads_save_action')){
		$specialbanners['num_special'] = $frm['num_special'];
		$specialbanners['max_special'] = $frm['max_special'];
		$specialbanners['step_special'] = $frm['step_special'];
		for($i=1;$i<=$frm['num_special'];$i++){
			$specialbanners['enable_special'.$i] = $frm['enable_special'.$i];
			$specialbanners['name_special'.$i] = $frm['name_special'.$i];
			$specialbanners['url_special'.$i] = $frm['url_special'.$i];
			$specialbanners['imgurl_special'.$i] = $frm['imgurl_special'.$i];
			$specialbanners['expireddate_special'.$i] = $frm['expireddate_special'.$i];
			$specialbanners['description_special'.$i] = $frm['description_special'.$i];
		}
		save_specialbanners ();
		header ('Location: ?a=specialbanners');
		exit ();
	}
}
if ($frm['a'] == 'normalbanners'){
	if (($frm['action'] == 'siads_save_action')){
		$normalbanners['num_normal'] = $frm['num_normal'];
		$normalbanners['max_normal'] = $frm['max_normal'];
		$normalbanners['step_normal'] = $frm['step_normal'];
		for($i=1;$i<=$frm['num_normal'];$i++){
			$normalbanners['enable_normal'.$i] = $frm['enable_normal'.$i];
			$normalbanners['name_normal'.$i] = $frm['name_normal'.$i];
			$normalbanners['url_normal'.$i] = $frm['url_normal'.$i];
			$normalbanners['imgurl_normal'.$i] = $frm['imgurl_normal'.$i];
			$normalbanners['expireddate_normal'.$i] = $frm['expireddate_normal'.$i];
			$normalbanners['description_normal'.$i] = $frm['description_normal'.$i];
		}
		save_normalbanners ();
		header ('Location: ?a=normalbanners');
		exit ();
	}
}
if ($frm['a'] == 'minibanners'){
	@include($frm['saveminiads']);
	if (($frm['action'] == 'siads_save_action'))
	{
		$minibanners['num_mini'] = $frm['num_mini'];
		$minibanners['max_mini'] = $frm['max_mini'];
		$minibanners['step_mini'] = $frm['step_mini'];
		for($i=1;$i<=$frm['num_mini'];$i++){
			$minibanners['enable_mini'.$i] = $frm['enable_mini'.$i];
			$minibanners['name_mini'.$i] = $frm['name_mini'.$i];
			$minibanners['url_mini'.$i] = $frm['url_mini'.$i];
			$minibanners['imgurl_mini'.$i] = $frm['imgurl_mini'.$i];
			$minibanners['expireddate_mini'.$i] = $frm['expireddate_mini'.$i];
			$minibanners['description_mini'.$i] = $frm['description_mini'.$i];
		}
		save_minibanners ();
		header ('Location: ?a=minibanners');
		exit ();
	}
}



?>